package com.meshnetics.gb;

import java.util.Collection;

/**
 * The context of the execution.
 *
 * @author mmarkov
 */
public interface Context {
    /**
     * Returns the Parameter with the given name or null if it is not found.
     *
     * @param name the name of the Parameter to search for
     * @return the Parameter with the given name or null if it is not found
     */
    Parameter getParameter(String name);

    /**
     * Returns the value of the Parameter with the given name or null if it is not found.
     *
     * @param name the name of the Parameter to search for
     * @return the value of the Parameter with the given name or null if it is not found
     */
    Object getValue(String name);

    /**
     * Returns the default value of the Parameter with the given name or null if it is not found.
     *
     * @param name the name of the Parameter to search for
     * @return the defaut value of the Parameter with the given name or null if it is not found
     */
    Object getDefaultValue(String name);

    /**
     * Adds the Paramter with the given name and value. The default value is set to null.
     *
     * @param name the name of the Parameter
     * @param val the value of the Parameter
     * @return previous Parameter with the same name or null if it was not set before
     */
    Parameter addParameter(String name, Object val);

    /**
     * Adds the Paramter with the given name, value and default value. If this parameter is already exists
     * then it's default value will not be modified.
     *
     * @param name the name of the Parameter
     * @param val the value of the Parameter
     * @param defaultVal the default value of the Parameter
     * @return previous Parameter with the same name or null if it was not set before
     */
    Parameter addParameter(String name, Object val, Object defaultVal);

    /**
     * Adds the given Parameter to the Context.
     *
     * @param param the Parameter to be set in the Context
     * @return previous Parameter with the same name or null if it was not set before
     */
    Parameter addParameter(Parameter param);

    /**
     * Removes the Parameter with the given name from the Context.
     *
     * @param name the name of the Paramtere to be removed
     * @return the removed Parameter or null if it was not set before
     */
    Parameter removeParameter(String name);

    /**
     * Returns the names of all paramters existing in this Context.
     *
     * @return the names of all paramters existing in this Context
     */
    Collection getParameterNames();

    /**
     * Returns all paramters existing in this Context.
     *
     * @return all paramters existing in this Context
     */
    Collection getParameters();

    /**
     * Resets all the parameters in the Context to their default values.
     */
    void reset();

    /**
     * Resets a Parameter with the given name to it's default value.
     *
     * @param name name of the Paramater to reset
     */
    void reset(String name);
}
